package com.indiv.pmy.input;

import java.util.HashMap;

public class KeyboardState {
	private HashMap<KeyValue,KeyState> valueStateMap;
	
	public KeyboardState() {
		valueStateMap = new HashMap<KeyValue,KeyState>();
	}
	
	public boolean isPressed(KeyValue key) {
		return valueStateMap.get(key)==KeyState.PRESSED; 
	}
	
	public boolean isNotPressed(KeyValue key) {
		return valueStateMap.get(key)==KeyState.NOTPRESSED;
	}
	
	protected void pushState(KeyValue key, KeyState state) {
		valueStateMap.put(key, state);
	}
	
	protected void removeState(KeyValue key) {
		valueStateMap.remove(key);
	}
	
	protected KeyboardState clone() {
		KeyboardState k = new KeyboardState();
		k.valueStateMap = (HashMap<KeyValue, KeyState>) valueStateMap.clone();
		return k;
	}
	
	protected void clearStates() {
		valueStateMap.clear();
	}
}
